<template>
  <van-tabbar v-model="tabbar" :placeholder="placeholder" @change="handleTabbarChange">
    <van-tabbar-item icon="wap-home-o" name="index">首页</van-tabbar-item>
    <van-tabbar-item icon="apps-o" name="bookshelf">书架</van-tabbar-item>
  </van-tabbar>
</template>

<script>
import Taro from "@tarojs/taro";
export default {
  name: "PageTabbar",
  props: {
    tabbarActive: {
      type: String,
      default: "index"
    },
    placeholder: Boolean
  },
  data() {
    return {
      tabbar: ""
    };
  },
  created() {
    this.tabbar = this.tabbarActive;
  },
  methods: {
    handleTabbarChange(name) {
      Taro.redirectTo({
        url: `/pages/${name}/${name}`
      });
    }
  }
};
</script>

<style scoped>
</style>